#include<stdio.h>

#include<stdlib.h>
int *twoSum(int numbers[], int n, int target)
{        
    if ((numbers == NULL)|(n < 2))
    {        
        return NULL;
    }
    int index1;
    int index2;
    int* ret = (int*)malloc(sizeof(int)*2);
    for (index1 = 0; index1 < n; ++index1)
    {        
        for (index2 = index1 + 1; index2 < n; ++index2)
        {        
            int sum_tmp = numbers[index1] + numbers[index2];
            if (sum_tmp == target)
            {        
                ret[0] = index1 + 1;
                ret[1] = index2 + 1;
                return ret;
            }
        }
    }
    return NULL;
}        
int main(int argc, char **argv)
{        
    int * array;
    int n,i;
    printf("Please input the array size\n");
    scanf("%d",&n);
    array = (int*)malloc(sizeof(int)*n);
    for(i=0; i < n; i++)
    {        
        printf("Please input the %d-th number\n",i);
        scanf("%d",&array[i]);
    }
    
    int target;
    printf("Please input the target number\n");
    scanf("%d",&target);
    int* result = twoSum(array, n, target);
    if (NULL != result)
    {        
        printf("The index1: %d; the index2: %d\n", result[0], result[1]);
        printf("values are %d and %d.\n", array[result[0]-1], array[result[1]-1]);
       
    }else
    {        
        printf("result is not available!\n");
    }
    free(result);//memory deallocation
}